<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Responsive Admin &amp; Dashboard Template based on Bootstrap 5">
    <meta name="author" content="AdminKit">
    <meta name="keywords" content="adminkit, bootstrap, bootstrap 5, admin, dashboard, template, responsive, css, sass, html, theme, front-end, ui kit, web">

    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link rel="shortcut icon" href="img/icons/icon-48x48.png" />

    <link rel="canonical" href="https://demo-basic.adminkit.io/pages-profile.html" />

    <title>信息修改</title>

    <link rel="stylesheet" href="https://unpkg.com/@adminkit/core@latest/dist/css/app.css">

    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="css/cropbox.css" type="text/css" />
</head>

<body>
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<div class="wrapper">
		<nav id="sidebar" class="sidebar js-sidebar">
			<div class="sidebar-content js-simplebar">
				<a class="sidebar-brand">
	      <span class="align-middle">考试系统</span>
	    </a>
	
				<ul class="sidebar-nav">
					<li class="sidebar-header">
								导航栏
							</li>
					
					
							<li class="sidebar-item">
								<a class="sidebar-link" href="teacher.html" th:if="${usertype} eq '0'" >
					  <i class="align-middle" data-feather="user"></i> <span class="align-middle">个人主页</span>
					</a>
					<a class="sidebar-link" href="/personpage3" th:if="${usertype} eq '1'" >
					  <i class="align-middle" data-feather="user"></i> <span class="align-middle">个人主页</span>
					</a>
					<a class="sidebar-link" href="admin.html" th:if="${usertype} eq '2'" >
					  <i class="align-middle" data-feather="user"></i> <span class="align-middle">个人主页</span>
					</a>
							</li>
					
							<li class="sidebar-item">
								<a class="sidebar-link" href="/myexam">
					  <i class="align-middle" data-feather="check-square"></i> <span class="align-middle">考试主页</span>
					</a>
							</li>
					
							<li class="sidebar-item">
								<a class="sidebar-link" href="/class">
					  <i class="align-middle" data-feather="book"></i> <span class="align-middle">课程主页</span>
					</a>
							</li>
					
							<li class="sidebar-item">
								<a class="sidebar-link" href="/questionbankpage">
					  <i class="align-middle" data-feather="map"></i> <span class="align-middle">题库练习</span>
					</a>
							</li>
							<li class="sidebar-item" th:if="${usertype} eq '0'">
										<a class="sidebar-link" href="/AddExaminfo">
							  <i class="align-middle" data-feather="file"></i> <span class="align-middle">上传考试</span>
							</a>
									</li>
				</ul>
			</div>
		</nav>
	
		<div class="main">
			<nav class="navbar navbar-expand navbar-light navbar-bg">
				<a class="sidebar-toggle js-sidebar-toggle">
					<i class="hamburger align-self-center"></i>
				</a>
	
				<div class="navbar-collapse collapse">
					<ul class="navbar-nav navbar-align">
						<li class="nav-item dropdown">
							<a class="nav-icon dropdown-toggle d-inline-block d-sm-none" href="#" data-bs-toggle="dropdown">
								<i class="align-middle" data-feather="settings"></i>
							</a>
	
							<a class="nav-link dropdown-toggle d-none d-sm-inline-block" href="#" data-bs-toggle="dropdown">
								<i class="align-middle me-2" data-feather="feather"></i>
								<span th:if="${usertype} eq '0'">老师</span>
								<span th:if="${usertype} eq '1'">学生</span>
								<span th:if="${usertype} eq '2'">管理员</span>
								<img src="images/someicon/teacher.jpg" class="avatar img-fluid rounded me-1" alt="老师" th:if="${usertype} eq '0'"/> 
								<img src="images/someicon/student.jpg" class="avatar img-fluid rounded me-1" alt="学生" th:if="${usertype} eq '1'"/> 
								<img src="images/someicon/admin.jpg" class="avatar img-fluid rounded me-1" alt="管理员" th:if="${usertype} eq '2'"/> 
								<span class="text-dark" th:text="${usermail}"></span>
							</a>
							<div class="dropdown-menu dropdown-menu-end">
								<a class="dropdown-item" href="teacherinfoupdate" th:if="${usertype} eq '0'"><i class="align-middle me-1" data-feather="user"></i> 修改信息</a>
								<a class="dropdown-item" href="/newstudentInformation" th:if="${usertype} eq '1'"><i class="align-middle me-1" data-feather="user"></i>  修改信息</a>
								<a class="dropdown-item" href="admininfoupdate" th:if="${usertype} eq '2'"><i class="align-middle me-1" data-feather="user"></i>  修改信息</a>
								<div class="dropdown-divider"></div>
								<a class="dropdown-item" href="logout">Log out</a>
							</div>
						</li>
					</ul>
				</div>
			</nav>
        <main class="content">
            <div class="container-fluid p-0">

                <div class="mb-3">
                    <h1 class="h3 d-inline align-middle">修改个人信息</h1>

                </div>
                <form action="/teainfoupdatesub" method="post" id="teacheredit" >
                    <div class="row">

                        <div class="col-md-3">
                            <div class="card">
                                <div class="card-header">

                                    <h5 class="card-title mb-0">用户头像</h5>
                                </div>
                                <div class="card-body text-center">
<!--                                    <div class="imageBox" style="height: 170px;background-image: url(../static/img/book1.jpg);">-->
<!--                                        </div>-->
                                    <div class="imageBox" th:style="'height: 170px;background-image:url(' + ${teacherinfo.headshot} + ');'">

                                    </div>


                                    <!-- <input type="file" id="file" style=" width: 200px">-->
                                    <div class="new-contentarea tc">
                                        <a href="javascript:void(0)" class="upload-img">
                                            <label for="upload-file">选择文件</label>
                                        </a>
                                        <!-- <input type="file" class="" name="upload-file" id="upload-file" /> -->
                                        <input type="file" name="file"  id="upload-file" >

                                    </div>




                                </div>
                            </div>
                        </div>
                        <div class="col-md-9">
                            <div class="card">
                                <div class="card-header">

                                    <h5 class="card-title mb-0">个人信息</h5>
                                </div>
                                <div class="card-body">

                                    <div class="mb-3">
                                        <label class="form-label">用户名</label>
                                        <input class="form-control form-control-lg" type="text" name="username" id="username" th:value="${teacherinfo.username}"  >
                                        <span></span>
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">密码</label>
                                        <input  class="form-control form-control-lg" type="password"  name="userpassword" id="userpassword" th:value="${teacherinfo.password}">
                                        <span></span>
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">确认密码</label>
                                        <input  class="form-control form-control-lg" type="password" name="ruserpassword" id="ruserpassword" th:value="${teacherinfo.password}">
                                        <span></span>
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">性别 </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="usergender" id="uesrgender1" value="0" checked> 男
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="usergender" id="uesrgender2"  value="1"> 女
                                        </label>

                                        <span></span>
                                    </div>
                                    <div class="mb-3">
                                        <label class="form-label">学院</label>
                                        <input class="form-control form-control-lg" type="text"  name="useracademy" id="useracademy" th:value="${teacherinfo.academy}">
                                        <span></span>
                                    </div>

                                    <div class="mb-3">
                                        <label class="form-label">系</label>
                                        <input type="text" class="form-control form-control-lg"  name="department" id="department" th:value="${teacherinfo.department}" >
                                        <span></span>
                                    </div>


                                    <div class="mb-3">
                                        <label class="form-label">职称</label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle0" value="0" checked> 讲师
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle1"  value="1"> 副教授
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle2"  value="2"> 教授
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle3"  value="3"> 副研究员
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle4"  value="4"> 研究员
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" name="jobtitle" id="jobtitle5"  value="5"> 助理教师
                                        </label>

                                        <span></span>
                                    </div>


                                    <div class="text-center mb-3">
                                        <input style="align-items: center" type="submit" value="确认修改" class="btn btn-success btn-bg text-left">

                                    </div>


                                    <script>
                                        function mySubmit(flag){
                                            return flag;
                                        }
                                        $("#teacheredit").submit(function () {
                                            if($("#userpassword").val()==''||$("#username").val()==''
                                                || $("#usermail").val()==''||$("#department").val()==''
                                                ||$("#useracademy").val()==''
                                            ){
                                                alert("请填入完整读者信息！");
                                                return mySubmit(false);
                                            }
                                        })
                                    </script>




                                </div>
                            </div>
                        </div>



                    </div>
                </form>

            </div>
        </main>

    </div>
</div>

<script src="https://unpkg.com/@adminkit/core@latest/dist/js/app.js"></script>

<script type="text/javascript" src="js/cropbox.js"></script>
<script type="text/javascript">
    $(window).on('load',function() {
        //设置默认头像为images/avatar.png
        var options =
            {
                thumbBox: '.thumbBox',
                spinner: '.spinner',

            }
        var cropper = $('.imageBox').cropbox(options);
        //选择文件则打开相应的文件
        $('#upload-file').on('change', function(){
            var reader = new FileReader();
            reader.onload = function(e) {
                options.imgSrc = e.target.result;
                cropper = $('.imageBox').cropbox(options);
            }
            reader.readAsDataURL(this.files[0]);

            setTimeout(function(){
                $('#btnCrop').click();
            },200);
        })


    });
</script>
<script type="text/javascript" src="js/jqueryform.js"></script>

<script type="text/javascript" src="js/tearegister.js"></script>
<script type="text/javascript" src="js/common.js"></script>


<script>// prepare the form when the DOM is ready
$(document).ready(function() {
    var options =
        {
        url:        'teainfoupdatesub',   // target element(s) to be updated with server response
        type:        'POST',
        dataType:     "json",
        success:       function (data){
            if (data.alert.trim()==='suc'){
                alert("更新成功！");
                window.parent.location.href = "teacher.html";}
            else {
                alert("更新失败！")
                }
            }
        };

    // bind form using 'ajaxForm'
    $('#teacheredit').ajaxForm(options);
}); </script>

</body>

</html>